package com.eastdigit.shiro.mgt;

import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.util.WebUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by acer on 15-2-1.
 */
public class SessionStorageEvaluator implements org.apache.shiro.mgt.SessionStorageEvaluator {
    @Override
    public boolean isSessionStorageEnabled(Subject subject) {
        boolean enabled = true;
        if (WebUtils.isWeb(subject)) {
            HttpServletRequest request = WebUtils.getHttpRequest(subject);
            String url = request.getServletPath();
            if (url != null && url.startsWith("/less/")) {// 手机端无状态登录
                enabled = false;
            }
        } else {
            enabled = false;
        }

        return enabled;
    }
}
